﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Microsoft.VisualStudio.Modeling;

namespace Project.Co_DataTransformationPrototype
{
    /// <summary>
    /// Abstract class for handling raised model modification events
    /// </summary>
    public abstract class Logger
    {

        /// <summary>
        /// Event definition
        /// </summary>
        public virtual event EventHandler<ModelEventArgs> CollectionChanged;

        /// <summary>
        /// Notification of change to events collection
        /// </summary>
        /// <param name="eventCollection"></param>
        protected virtual void OnCollectionChanged(IDictionary<Guid, ElementEventInfo> eventCollection)
        {
            EventHandler<ModelEventArgs> handler = CollectionChanged;
            if (handler != null)
            {
                ModelEventArgs e = new ModelEventArgs();
                e.collection = eventCollection;
                handler(this, e);
            }
        }

        /// <summary>
        /// Used to skip recording events
        /// </summary>
        public bool blnDisableChangeTracking = false;

        /// <summary>
        /// Listener method called on creation of instances of the Entity class.
        /// Called once per instance that was added.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        public abstract void elementAdded(object sender, ElementAddedEventArgs e);
        /// <summary>
        /// Listener method called after deletion of instances of Entity.
        /// Called once per instance that was deleted.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        public abstract void elementRemoved(object sender, ElementDeletedEventArgs e);
        /// <summary>
        /// Listener method called after a change to a property of an Entity.
        /// Same method is called for changes to any of the instance's properties
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        public abstract void elementUpdated(object sender, ElementPropertyChangedEventArgs e);
        /// <summary>
        /// Listener method called after a link creation between Elements.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        public abstract void linkAdded(object sender, ElementAddedEventArgs e);
        /// <summary>
        /// Listener method called after a link removal between Elements.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        public abstract void linkRemoved(object sender, ElementDeletedEventArgs e);
        /// <summary>
        /// Listener method called after a change to a property of a link.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        public abstract void linkUpdated(object sender, ElementPropertyChangedEventArgs e);
        
        public abstract void attributeAdded(object sender, ElementAddedEventArgs e);
        public abstract void attributeRemoved(object sender, ElementDeletedEventArgs e);
        public abstract void attributeUpdated(object sender, ElementPropertyChangedEventArgs e);

        public abstract void transactionCommited(object sender, TransactionCommitEventArgs e);
        public abstract void transactionRolledback(object sender, TransactionRollbackEventArgs e);
    }
}
